package screen;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.geom.Ellipse2D;

import javax.swing.JButton;
import javax.swing.JFrame;

import panel.Ajou;

@SuppressWarnings("serial")
public class Loading extends JFrame implements KeyListener, ActionListener{

	/*Another Screen*/
	Main main;
	
	/*Panel*/
	Ajou ajou;

	/*Component*/
	JButton help, exit;
	
	/*interrupt*/
	boolean interrupt;

	public Loading(Main main) {
		
		this.main = main;
		
		/*Panel*/
		ajou = new Ajou();
		setContentPane(ajou);
		
		/*Frame*/
		setBackground(new Color(0,0,255));
		setLayout(null);
		setSize(336, 337);
		setUndecorated(true);
		setLocationRelativeTo(null);
		setVisible(true);
		setShape(new Ellipse2D.Double(0,0,getWidth(),getHeight()));
		
		/*Component*/
		help = new JButton("HELP");
		exit = new JButton("EXIT");
		help.setBounds(68, 250, 70, 40);
		exit.setBounds(201, 250, 70, 40);
		add(help);
		add(exit);
		
		/*Listener*/
		addKeyListener(this);
		help.addActionListener(this);
		exit.addActionListener(this);
		this.requestFocus();
	}

	public Ajou getAjou() {
		return ajou;
	}
	
	public boolean isInterrupt(){
		return interrupt;
	}
	
	public void keyPressed(KeyEvent e) {
		// TODO Auto-generated method stub
		main.setEnabled(true);
		interrupt = true;
		dispose();
	}

	@Override
	public void keyTyped(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyReleased(KeyEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		Component c = (Component) e.getSource();
		if(c == help){
			this.requestFocus();
			//working any thing...
		}
		else{
			System.exit(1);
		}
		
	}
}
